document.getElementById('submit_btn').onclick = function () {
    var xhr;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xhr = new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            if (xhr.responseText.trim() == 'success') {
                alert('保存成功!');
                window.location.href = '/index.html';
            } else {
                alert('保存失败!');
            }
        }
    };

    xhr.open('POST', '/cgi-bin/storage.cgi', true);
    //xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    //xhr.setRequestHeader('Content-type', 'multipart/form-data');
    xhr.send(new FormData(document.getElementById('form')));
};